package controllers

import (
	"net/http"

	"github.com/gin-gonic/gin"
)

type Response struct {
	Code ReCode      `json:"code"`
	Msg  interface{} `json:"mag"`
	Data interface{} `json:"data"`
}

func ResponseError(c *gin.Context, code ReCode) {
	c.JSON(http.StatusOK,&Response{
		Code: code,
		Msg: code.GetCodeMsg(),
		Data: nil,
	})
}

func ResonseErrorWithMsg(c *gin.Context, code ReCode,msg string){
	c.JSON(http.StatusOK,&Response{
		Code: code,
		Msg: msg,
		Data: nil,
	})
}
func ResponseSuccess(c *gin.Context, code ReCode,msg string, data1 interface{}){
	c.JSON(http.StatusOK,&Response{
		Code: code,
		Msg: msg,
		Data: data1,
	})
}